import {
  guid2
} from '../utils'

let $state = {};
let $getters = {};

['article'].forEach(e => {
  let k = `${e}Flag`
  $state[k] = ""
  $getters[k] = (states)=>{return states[k]}
})

$state.tagsRecommand = [];

const state = {...$state}
const getters = {...$getters}

const mutations = {
  SET_UPDATE_FLAG: (state, k) => {
    state[k] = guid2();
  },
  SET_TAGS_RECOMMAND: (states, tags) => {
    states.tagsRecommand = [...tags];
  },
}

const actions = {
  updateStateFlag({
    commit
  }, key) {
    let k = `${key}Flag`
    commit('SET_UPDATE_FLAG', k)
  },
  setTagsRecommand({
    commit
  }, tags) {
    commit('SET_TAGS_RECOMMAND', tags)
  },
}

export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions
}
